package com.kgcx.coupon.controller;

import com.github.pagehelper.PageHelper;
import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.coupon.domain.UserPlan;
import com.kgcx.coupon.query.UserPlanQuery;
import com.kgcx.coupon.service.UserPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 何凯
 * @version 0.1
 * @description
 * @time 2017/12/27 16:08
 * @since 0.1
 */
@Api(description = "用户营销方案", tags = "用户营销方案接口")
@RestController
@RequestMapping("coupon/v1/userPlan")
public class UserPlanController extends BaseController{
    @Autowired
    private UserPlanService userPlanService;
     /**
     * 主动发送历史查询
     * @param query
     * @return
     */
    @ApiOperation(value = "主动发送历史查询", httpMethod = "POST", notes = "主动发送历史查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping(value = "queryPullWithPage")
    public ReturnData<List<UserPlan>> queryPullWithPage(@RequestBody UserPlanQuery query){
        PageHelper.startPage(query.getPageNum(),query.getPageSize());
        List<UserPlan> list= userPlanService.selectForList(query);
        return new ReturnData<>(list);
    }

    /**
     * 营销方案领取历史查询
     * @param query
     * @return
     */
    @ApiOperation(value = "营销方案领取历史查询", httpMethod = "POST", notes = "营销方案领取历史查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping(value = "queryPushWithPage")
    public ReturnData<List<UserPlan>> queryPushWithPage(@RequestBody UserPlanQuery query){
        PageHelper.startPage(query.getPageNum(),query.getPageSize());

        List<UserPlan> list= userPlanService.selectForList(query);
        return new ReturnData<>(list);
    }
}
